<?php

/**
 * This is the model class for table "detalle_movimientos".
 *
 * The followings are the available columns in table 'detalle_movimientos':
 * @property integer $detalle_movimientos_id
 * @property integer $productos_id
 * @property integer $cantidad
 * @property double $subtotal
 * @property integer $movimientos_id
 *
 * The followings are the available model relations:
 * @property Movimientos $movimientos
 * @property Productos $productos
 */
class DetalleMovimientos extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return DetalleMovimientos the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'detalle_movimientos';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('productos_id, cantidad, subtotal, movimientos_id', 'required'),
			array('productos_id, cantidad, movimientos_id', 'numerical', 'integerOnly'=>true),
			array('subtotal', 'numerical'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('detalle_movimientos_id, productos_id, cantidad, subtotal, movimientos_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'movimientos' => array(self::BELONGS_TO, 'Movimientos', 'movimientos_id'),
			'productos' => array(self::BELONGS_TO, 'Productos', 'productos_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'detalle_movimientos_id' => 'Detalle Movimientos',
			'productos_id' => 'Productos',
			'cantidad' => 'Cantidad',
			'subtotal' => 'Subtotal',
			'movimientos_id' => 'Movimientos',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('detalle_movimientos_id',$this->detalle_movimientos_id);
		$criteria->compare('productos_id',$this->productos_id);
		$criteria->compare('cantidad',$this->cantidad);
		$criteria->compare('subtotal',$this->subtotal);
		$criteria->compare('movimientos_id',$this->movimientos_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}